Optimal. Leaf size=89 \[ \frac {(A b-a B) x}{b^2}-\frac {2 a (A b-a B) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} b^2 \sqrt {a+b} d}+\frac {B \sin (c+d x)}{b d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.11, antiderivative size = 89, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 29, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.207, Rules used = {3047, 3102, 12,
2814, 2738, 211} \begin {gather*} -\frac {2 a (A b-a B) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{b^2 d \sqrt {a-b} \sqrt {a+b}}+\frac {x (A b-a B)}{b^2}+\frac {B \sin (c+d x)}{b d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 211
Rule 2738
Rule 2814
Rule 3047
Rule 3102
Rubi steps
\begin {align*} \int \frac {\cos (c+d x) (A+B \cos (c+d x))}{a+b \cos (c+d x)} \, dx &=\int \frac {A \cos (c+d x)+B \cos ^2(c+d x)}{a+b \cos (c+d x)} \, dx\\ &=\frac {B \sin (c+d x)}{b d}+\frac {\int \frac {(A b-a B) \cos (c+d x)}{a+b \cos (c+d x)} \, dx}{b}\\ &=\frac {B \sin (c+d x)}{b d}+\frac {(A b-a B) \int \frac {\cos (c+d x)}{a+b \cos (c+d x)} \, dx}{b}\\ &=\frac {(A b-a B) x}{b^2}+\frac {B \sin (c+d x)}{b d}-\frac {(a (A b-a B)) \int \frac {1}{a+b \cos (c+d x)} \, dx}{b^2}\\ &=\frac {(A b-a B) x}{b^2}+\frac {B \sin (c+d x)}{b d}-\frac {(2 a (A b-a B)) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{b^2 d}\\ &=\frac {(A b-a B) x}{b^2}-\frac {2 a (A b-a B) \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} b^2 \sqrt {a+b} d}+\frac {B \sin (c+d x)}{b d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.23, size = 85, normalized size = 0.96 \begin {gather*} \frac {(A b-a B) (c+d x)-\frac {2 a (-A b+a B) \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2}}+b B \sin (c+d x)}{b^2 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.20, size = 110, normalized size = 1.24
method | result | size |
derivativedivides | \(\frac {-\frac {2 a \left (A b -a B \right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{b^{2} \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {\frac {2 B b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )}+2 \left (A b -a B \right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b^{2}}}{d}\) | \(110\) |
default | \(\frac {-\frac {2 a \left (A b -a B \right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{b^{2} \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {\frac {2 B b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )}+2 \left (A b -a B \right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b^{2}}}{d}\) | \(110\) |
risch | \(\frac {x A}{b}-\frac {a B x}{b^{2}}-\frac {i {\mathrm e}^{i \left (d x +c \right )} B}{2 b d}+\frac {i {\mathrm e}^{-i \left (d x +c \right )} B}{2 b d}-\frac {a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+a \sqrt {-a^{2}+b^{2}}}{\sqrt {-a^{2}+b^{2}}\, b}\right ) A}{\sqrt {-a^{2}+b^{2}}\, d b}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+a \sqrt {-a^{2}+b^{2}}}{\sqrt {-a^{2}+b^{2}}\, b}\right ) B}{\sqrt {-a^{2}+b^{2}}\, d \,b^{2}}+\frac {a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, d b}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) B}{\sqrt {-a^{2}+b^{2}}\, d \,b^{2}}\) | \(348\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.42, size = 322, normalized size = 3.62 \begin {gather*} \left [-\frac {2 \, {\left (B a^{3} - A a^{2} b - B a b^{2} + A b^{3}\right )} d x - {\left (B a^{2} - A a b\right )} \sqrt {-a^{2} + b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right ) - 2 \, {\left (B a^{2} b - B b^{3}\right )} \sin \left (d x + c\right )}{2 \, {\left (a^{2} b^{2} - b^{4}\right )} d}, -\frac {{\left (B a^{3} - A a^{2} b - B a b^{2} + A b^{3}\right )} d x - {\left (B a^{2} - A a b\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \cos \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (d x + c\right )}\right ) - {\left (B a^{2} b - B b^{3}\right )} \sin \left (d x + c\right )}{{\left (a^{2} b^{2} - b^{4}\right )} d}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 3225 vs.
\(2 (76) = 152\).
time = 63.54, size = 3225, normalized size = 36.24 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.48, size = 142, normalized size = 1.60 \begin {gather*} -\frac {\frac {{\left (B a - A b\right )} {\left (d x + c\right )}}{b^{2}} - \frac {2 \, B \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1\right )} b} + \frac {2 \, {\left (B a^{2} - A a b\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{\sqrt {a^{2} - b^{2}} b^{2}}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 1.12, size = 541, normalized size = 6.08 \begin {gather*} \frac {2\,B\,a\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d\,\left (a^2-b^2\right )}-\frac {2\,A\,b\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d\,\left (a^2-b^2\right )}-\frac {B\,b\,\sin \left (c+d\,x\right )}{d\,\left (a^2-b^2\right )}+\frac {2\,A\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b\,d\,\left (a^2-b^2\right )}-\frac {2\,B\,a^3\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b^2\,d\,\left (a^2-b^2\right )}+\frac {A\,a\,\ln \left (\frac {a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b\,d\,\sqrt {b^2-a^2}}-\frac {A\,a\,\ln \left (\frac {b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b\,d\,\sqrt {b^2-a^2}}-\frac {B\,a^2\,\ln \left (\frac {a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b^2\,d\,\sqrt {b^2-a^2}}+\frac {B\,a^2\,\ln \left (\frac {b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b^2\,d\,\sqrt {b^2-a^2}}+\frac {B\,a^2\,\sin \left (c+d\,x\right )}{b\,d\,\left (a^2-b^2\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________